package com.atcumt.Thread.create;

/* 三个线程T1，T2，T3，确保它们按顺序执行 */
public class testJoin {
    
    public static void main(String[] args) {
        Thread t1 = new Thread(new MyThreadTask("春天", 4));
        Thread t2 = new Thread(new MyThreadTask("夏天", 4));
        Thread t3 = new Thread(new MyThreadTask("秋天", 4));

        try{
            t1.start();
            t1.join();
            t2.start();
            t2.join();
            t3.start();
            t3.join();
        } catch (InterruptedException e){
            e.printStackTrace();
        }
    }
}

class MyThreadTask implements Runnable {
    
    private String name;
    private int count;

    public MyThreadTask(String name, int count) {
        this.name = name;
        this.count = count;
    }



    @Override
    public void run() {
        // TODO Auto-generated method stub
        for (int i = 1; i <= count ; i++) {
            System.out.println(this.name + "来了: " + i + "次");
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

}
